<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.2.4 - src/lzio.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - lzio.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.2.4</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">34</td>
            <td class="headerCovTableEntry">34</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:16</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: lzio.c,v 1.35.1.1 2013/04/12 18:48:47 roberto Exp $
<span class="lineNum">       3 </span>            : ** Buffered streams
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : 
<span class="lineNum">       8 </span>            : #include &lt;string.h&gt;
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : #define lzio_c
<span class="lineNum">      11 </span>            : #define LUA_CORE
<span class="lineNum">      12 </span>            : 
<span class="lineNum">      13 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      14 </span>            : 
<span class="lineNum">      15 </span>            : #include &quot;llimits.h&quot;
<span class="lineNum">      16 </span>            : #include &quot;lmem.h&quot;
<span class="lineNum">      17 </span>            : #include &quot;lstate.h&quot;
<span class="lineNum">      18 </span>            : #include &quot;lzio.h&quot;
<span class="lineNum">      19 </span>            : 
<span class="lineNum">      20 </span>            : 
<span class="lineNum">      21 </span><span class="lineCov">       1173 : int luaZ_fill (ZIO *z) {</span>
<span class="lineNum">      22 </span>            :   size_t size;
<span class="lineNum">      23 </span><span class="lineCov">       1173 :   lua_State *L = z-&gt;L;</span>
<span class="lineNum">      24 </span>            :   const char *buff;
<span class="lineNum">      25 </span>            :   lua_unlock(L);
<span class="lineNum">      26 </span><span class="lineCov">       1173 :   buff = z-&gt;reader(L, z-&gt;data, &amp;size);</span>
<span class="lineNum">      27 </span>            :   lua_lock(L);
<span class="lineNum">      28 </span><span class="lineCov">       1172 :   if (buff == NULL || size == 0)</span>
<span class="lineNum">      29 </span><span class="lineCov">        473 :     return EOZ;</span>
<span class="lineNum">      30 </span><span class="lineCov">        699 :   z-&gt;n = size - 1;  /* discount char being returned */</span>
<span class="lineNum">      31 </span><span class="lineCov">        699 :   z-&gt;p = buff;</span>
<span class="lineNum">      32 </span><span class="lineCov">        699 :   return cast_uchar(*(z-&gt;p++));</span>
<span class="lineNum">      33 </span>            : }
<span class="lineNum">      34 </span>            : 
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span><span class="lineCov">        510 : void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {</span>
<span class="lineNum">      37 </span><span class="lineCov">        510 :   z-&gt;L = L;</span>
<span class="lineNum">      38 </span><span class="lineCov">        510 :   z-&gt;reader = reader;</span>
<span class="lineNum">      39 </span><span class="lineCov">        510 :   z-&gt;data = data;</span>
<span class="lineNum">      40 </span><span class="lineCov">        510 :   z-&gt;n = 0;</span>
<span class="lineNum">      41 </span><span class="lineCov">        510 :   z-&gt;p = NULL;</span>
<span class="lineNum">      42 </span><span class="lineCov">        510 : }</span>
<span class="lineNum">      43 </span>            : 
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span>            : /* --------------------------------------------------------------- read --- */
<span class="lineNum">      46 </span><span class="lineCov">        371 : size_t luaZ_read (ZIO *z, void *b, size_t n) {</span>
<span class="lineNum">      47 </span><span class="lineCov">        738 :   while (n) {</span>
<span class="lineNum">      48 </span>            :     size_t m;
<span class="lineNum">      49 </span><span class="lineCov">        368 :     if (z-&gt;n == 0) {  /* no bytes in buffer? */</span>
<span class="lineNum">      50 </span><span class="lineCov">         14 :       if (luaZ_fill(z) == EOZ)  /* try to read more */</span>
<span class="lineNum">      51 </span><span class="lineCov">          1 :         return n;  /* no more input; return number of missing bytes */</span>
<span class="lineNum">      52 </span>            :       else {
<span class="lineNum">      53 </span><span class="lineCov">         13 :         z-&gt;n++;  /* luaZ_fill consumed first byte; put it back */</span>
<span class="lineNum">      54 </span><span class="lineCov">         13 :         z-&gt;p--;</span>
<span class="lineNum">      55 </span>            :       }
<span class="lineNum">      56 </span>            :     }
<span class="lineNum">      57 </span><span class="lineCov">        367 :     m = (n &lt;= z-&gt;n) ? n : z-&gt;n;  /* min. between n and z-&gt;n */</span>
<span class="lineNum">      58 </span><span class="lineCov">        367 :     memcpy(b, z-&gt;p, m);</span>
<span class="lineNum">      59 </span><span class="lineCov">        367 :     z-&gt;n -= m;</span>
<span class="lineNum">      60 </span><span class="lineCov">        367 :     z-&gt;p += m;</span>
<span class="lineNum">      61 </span><span class="lineCov">        367 :     b = (char *)b + m;</span>
<span class="lineNum">      62 </span><span class="lineCov">        367 :     n -= m;</span>
<span class="lineNum">      63 </span>            :   }
<span class="lineNum">      64 </span><span class="lineCov">        370 :   return 0;</span>
<span class="lineNum">      65 </span>            : }
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span>            : /* ------------------------------------------------------------------------ */
<span class="lineNum">      68 </span><span class="lineCov">       9533 : char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) {</span>
<span class="lineNum">      69 </span><span class="lineCov">       9533 :   if (n &gt; buff-&gt;buffsize) {</span>
<span class="lineNum">      70 </span><span class="lineCov">        507 :     if (n &lt; LUA_MINBUFFER) n = LUA_MINBUFFER;</span>
<span class="lineNum">      71 </span><span class="lineCov">        507 :     luaZ_resizebuffer(L, buff, n);</span>
<span class="lineNum">      72 </span>            :   }
<span class="lineNum">      73 </span><span class="lineCov">       9533 :   return buff-&gt;buffer;</span>
<span class="lineNum">      74 </span>            : }
<span class="lineNum">      75 </span>            : 
<span class="lineNum">      76 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
